<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登陆</title>
<link href="__PUBLIC__/Home/css/css.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__PUBLIC__/Admin/js/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Common/Layer/layer.js"></script>
</head>

<body>
<div class="head">
    <a href="{:U('Index/index')}"><img style="width:178px; height:80px;" src="__PUBLIC__/Home/img/logo.png" ></a>
    <span class="size28">找回密码</span>
</div>
<div class="content-bj">
	<h2 style="text-align:center;margin-top:50px;">找回密码</h2>
<form action="{:U('Public/update_pwd')}" method="post" onsubmit="return check();">
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="pwd_table" style="margin-top:100px;">
                  <tr>
                    <td width="45%"><div align="right">手机号：</div></td>
                    <td width="55%">
                    <input type="text" name="mobile" id="mobile" style="height:30px;border:1px solid #CCC;" value="{$_SESSION['mobile']}"></td>
      </tr>
                  <tr>
                    <td height="36"><div align="right">请填写手机校验码：</div></td>
                    <td><input type="text" name="sms_code" id="sms_code" style="border:1px solid #CCC; width:60px; height:26px; ">
                    	<input type="button" style=" width:120px; height:26px;color:#FFF; background:#555; border-radius:3px;" id="btn" value="免费获取验证码" onclick="sendCode(this);" />
                    </td>
                  </tr>
                  <tr>
                    <td height="37"><div align="right">新密码：</div></td>
                    <td><input type="password" name="password" id="password" style="border:1px solid #CCC; height:26px;"></td>
                  </tr>
                  <tr>
                    <td height="36"><div align="right">重复新密码：</div></td>
                    <td><input type="password" name="repassword" id="repassword" style="border:1px solid #CCC; height:26px;"></td>
                  </tr>
                  <tr>
                    <td height="53">&nbsp;</td>
                    <td><input type="submit" name="submit" value="提交" style=" padding:5px 60px; border-radius:3px; background:#4ecf5b; color:#FFF;"></td>
                  </tr>
                  <tr>
                    <td height="64" colspan="2"><div align="center"></div></td>
                  </tr>
    </table>
				</form>
<input type="hidden" id="hidden_sms">

<script>
//发送短信
var clock = '';
var nums = 45; //有效时间(秒)
var btn;
function sendCode(thisBtn){ 
  var mobile = $('#mobile').val();
  if(!checkMobile(mobile)){
    alert('请输入正确的手机号');
    return false;
  }else{
    btn = thisBtn;
    btn.disabled = true; //将按钮置为不可点击
    btn.value = nums+' 秒后重试';
    clock = setInterval(doLoop, 1000); //一秒执行一次
    //提交短信
    $.get("{:U('Public/ajax_send_mobile')}", { mobile:mobile },function(data){
      $('#hidden_sms').val(data);
    });
  }
}
//倒计时
function doLoop(){
  nums--;
  if(nums > 0){
    btn.value = nums+' 秒后重试';
  }else{
    clearInterval(clock); //清除js定时器
    btn.disabled = false;
    btn.value = '重新获取';
    nums = 45; //重置时间
  }
}
//检查手机号合法
function checkMobile(str) {
    var re = /^1\d{10}$/
    if (re.test(str)) {
        return true;
    } else {
        return false;
    }
}
</script>
<script>
function check(){
  var mobile = $('#mobile').val();
  if(mobile == ''){
    alert('手机号不能为空');
    return false;
  }
  var sms_code = $('#sms_code').val();
  if(sms_code == ''){
    alert('验证码不正确');
    return false;
  }
  var password = $('#password').val();
  if(password == ''){
    alert('密码不能为空');
    return false;
  }
  var repassword = $('#repassword').val();
  if(password != repassword){
    alert('重复密码不正确');
    return false;
  }
  return true;
}
</script>

    
</div>

  <div style="margin-top:100px;">
    <div align="center">版权所有：掌中游互联网信息服务股份有限公司 2016版权所有 ICP：沪ICP备16022678号-1</div>
  </div>
</body>
</html>
